package com.dks.controller.teacher;


import com.dks.repository.ICourseRepository;
import com.dks.repository.ITeacherRepository;
import com.dks.repository.impl.CourseRepository;
import com.dks.result.Result;
import com.dks.result.ResultInfo;
import com.dks.result.ResultModel;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("teacher")
@RestController
public class TeacherController {

    private ITeacherRepository teacherRepository;

    @Autowired
    private CourseRepository courseRepository;


    @Autowired
    public TeacherController(final ITeacherRepository teacherRepositoryIn) {
        this.teacherRepository = teacherRepositoryIn;
    }


    /**
     * @Author: Ah Nan
     * @Description: 获取课程授课教师列表
     * @Date: 9:52 2020/4/23
     * @Modificd By:
     * @Param: courseStage 课程类别
     * @Param: name 老师名字
     * @Param: pageNum 页码
     * @Param: pageSize 条数
     * @return:
     * @throw: 请描述异常信息
     */
    @GetMapping("get-course-teacher-list")
    public ResultModel<Object> getCourseTeacherList(String courseStage, String name, Integer pageNum, Integer pageSize) {
        if (courseStage == null || courseStage.isEmpty()) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "courseStage课程类别不能为空");
        }
        if (null == pageNum) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "pageNum");
        }
        if (null == pageSize) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "pageSize");
        }
        return teacherRepository.getCourseTeacherList(courseStage, name, pageNum, pageSize);
    }

    /**
     * @Author: Ah Nan
     * @Description: 获取教师详情
     * @Date: 9:52 2020/4/23
     * @Modificd By:
     * @Param: teacherId 教师id
     * @return:
     * @throw: 请描述异常信息
     */
    @GetMapping("get-teacher-info")
    public ResultModel<Object> getTeacherInfo(Integer teacherId,Integer userId) {
        if (null == teacherId) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "teacherId");
        }
        if (null == userId) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "userId");
        }
        return teacherRepository.getTeacherInfo(teacherId,userId);
    }

    /**
     * @Author: Ah Nan
     * @Description: 教务端 获取教师的课程列表
     * @Date: 9:52 2020/4/23
     * @Modificd By:
     * @Param: teacherId 老师id
     * @Param: pageNum 页码
     * @Param: pageSize 条数
     * @return:
     * @throw: 请描述异常信息
     */
    @GetMapping("tc-get-teacher-course-list")
    public ResultModel<Object> tcGetTeacherCourseList(String beginTime, String endTime, String courseCategory, Integer teacherId, Integer pageNum, Integer pageSize) {
        if (null == teacherId) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "teacherId");
        }
        if (null == pageNum) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "pageNum");
        }
        if (null == pageSize) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "pageSize");
        }
        return teacherRepository.tcGetTeacherCourseList(beginTime, endTime, courseCategory, teacherId, pageNum, pageSize);
    }

    /**
     * @Author: Ah Nan
     * @Description: 【教务】获取系统的全部课表
     * @Date: 9:52 2020/4/23
     * @Modificd By:
     * @Param: teacherId 老师id
     * @Param: pageNum 页码
     * @Param: pageSize 条数
     * @return:
     * @throw: 请描述异常信息
     */
    @GetMapping("tc-get-all-teacher-course-list")
    public ResultModel<Object> tcGetAllTeacherCourseList(Long teacherId,String beginTime, String endTime, String courseCategory, Integer pageNum, Integer pageSize, String studentBirthDay) {
        if (null == pageNum) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "pageNum");
        }
        if (null == pageSize) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "pageSize");
        }
        return teacherRepository.tcGetAllTeacherCourseList(teacherId,beginTime, endTime, courseCategory, studentBirthDay, pageNum, pageSize);
    }

    /**
     * @Author: Ah Nan
     * @Description: 【教务】获取上课人员列表
     * @Date: 9:52 2020/4/23
     * @Modificd By:
     * @Param: teacherId 老师id
     * @Param: pageNum 页码
     * @Param: pageSize 条数
     * @return:
     * @throw: 请描述异常信息
     */
    @GetMapping("tc-get-student-course-list")
    public ResultModel<Object> tcGetStudentCourseList(String appointmentType, Integer classId, Integer pageNum, Integer pageSize) {
        if (null == pageNum) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "pageNum");
        }
        if (null == pageSize) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "pageSize");
        }
        return teacherRepository.tcGetStudentCourseList(appointmentType, classId, pageNum, pageSize);
    }

    /**
     * @Author: Ah Nan
     * @Description: 【教务】获取全部老师列表
     * @Date: 9:52 2020/4/23
     * @Modificd By:
     * @Param: teacherId 老师id
     * @Param: pageNum 页码
     * @Param: pageSize 条数
     * @return:
     * @throw: 请描述异常信息
     */
    @GetMapping("get-all-teacher-list")
    public ResultModel<Object> getAllTeacherList(String teacherName, Integer pageNum, Integer pageSize) {
        if (null == pageNum) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "pageNum");
        }
        if (null == pageSize) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "pageSize");
        }
        return teacherRepository.getAllTeacherList(teacherName, pageNum, pageSize);
    }

    /**
     * @Author: Ah Nan
     * @Description: 获取课程分类对应的老师列表
     * @Date: 9:52 2020/4/23
     * @Modificd By:
     * @Param: teacherId 老师id
     * @Param: pageNum 页码
     * @Param: pageSize 条数
     * @return:
     * @throw: 请描述异常信息
     */
    @GetMapping("get-course-category-teacher-list")
    public ResultModel<Object> getCourseCategoryTeacherList(Integer courseCategoryId, Integer pageNum, Integer pageSize) {
        if (null == pageNum) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "pageNum");
        }
        if (null == pageSize) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "pageSize");
        }
        return teacherRepository.getCourseCategoryTeacherList(courseCategoryId, pageNum, pageSize);
    }


    /**
     * @Author: kennychan
     * @Description: 【首页-教师端】获取待办列表
     * @Date: 9:52 2020/4/23
     * @Modificd By:
     * @Param: attendClassStatus 上课状态:0上课,1下课
     * @return:
     * @throw: 请描述异常信息
     */
    @GetMapping("get-todo-list")
    public ResultModel<Object> getTeacherToDoList(Integer pageNum, Integer pageSize,Long teacherId) {
        if (null == pageNum) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "pageNum");
        }
        if (null == pageSize) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "pageSize");
        }
        if (null == teacherId) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "teacherId");
        }
        return courseRepository.getTeacherToDoList(pageNum,pageSize,teacherId);
    }

}
